#include<bits/stdc++.h>
#define int long long
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
struct cars{
  int d,v,a;
}c[100010];
struct count{
  int nums,id;
}cnt[100010];
bool p[100010];
bool cmp(count x,count y){
  return x.nums < y.nums;
}
void solve(){
  int n,m,len,V;
  int mxa = -1,mxp = -1;
  cin >> n >> m >> len >> V;
  for(int i = 1;i <= n;i++){
    cin >> c[i].d >> c[i].v >> c[i].a;
    mxa = max(mxa,c[i].a);
  }
  for(int i = 1;i <= m;i++){
    int x;
    cin >> x;
    p[i] = x;
    mxp = max(mxp,x);
  }
  if(mxa == 0){
    bool f = 0;
    int ans1 = 0;
    for(int i = 1;i <= n;i++){
      if(c[i].v <= V) continue;
      if(mxp >= c[i].d){
	f = 1;
	ans1++;
      }
    }
    cout << ans1 << " ";
    if(f) cout << m - 1;
    else cout << m;
    cout << "\n";
    return ;
  }
  sort(p + 1,p + 1 + m);
  int ans1 = 0;
  int sum = 0;
  for(int i = 1;i <= n;i++){
    if(mxp < c[i].d) continue;
    bool f = 0;
    for(int j = m;j >= 1;j--){
      if(p[j] < c[i].d) break;
      int s = p[j] - c[i].d;
      double nv = sqrt(c[i].v * c[i].v + 2 * c[i].a * s);
      if(nv > V){
	f = 1;
	cnt[j].id = j;
	cnt[j].nums++;
	sum++;
      }
    }
    if(f) ans1++;
  }
  cout << ans1 << " ";
  sort(cnt + 1,cnt + 1 + m,cmp);
  int ans2 = 0;
  for(int i = 1;i <= m;i++){
    if(sum - cnt[i].nums >= ans1) ans2++;
    else break;
  }
  cout << ans2 << "\n";
  return ;
}
signed main(){
  freopen("detect.in","r",stdin);
  freopen("detect.out","w",stdout);
  IOS;
  int t;
  cin >> t;
  while(t--){
    solve();
  }
  return 0;
}